<template>
    <el-select v-model="nowValue" clearable :placeholder="$t('province')">
        <el-option
            v-for="item in lists"
            :label="item.name"
            :value="item.adcode"
            :key="item.adcode"
        ></el-option>
    </el-select>
</template>
<script>
import {getDistrictList} from '../../api/district'
export default {
    name: "ProvinceSelect",
    props: ["nowProvince"],
    data() {
        return {
            lists: [],
            nowValue: this.nowProvince
        };
    },
    created() {
        this.setList();
    },
    methods:{
        async setList(){
            let response = await getDistrictList();
            if(response.status == 200 && response.data.data){
                this.lists = response.data.data;
            }
        }
    },
    watch:{
        nowValue(newVal){
            this.$emit("update:nowProvince",newVal)
        },
        nowProvince(newVal){
            this.nowValue = newVal;
        }
    }
};
</script>
